package com.sgb.kjwl.view.ui.adapter.device;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.DeviceOutEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.MDateUtil;

import java.util.List;

public class DeviceOutAdapter extends BaseRecycleAdapter<DeviceOutEntity> {

    private TextView timeView;

    public DeviceOutAdapter(Context context, List<DeviceOutEntity> datas) {
        super(context, R.layout.item_device_out, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final DeviceOutEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        timeView = holder.getItem().findViewById(R.id.time_view);
        TextView priceView = holder.getItem().findViewById(R.id.price_view);
        if (entity.getNegotiable() == 1){
            priceView.setText("面议");
        }else {
            priceView.setText(entity.getPrice()+entity.getUnitName());
        }

        try {
            timeView.setText(MDateUtil.getByTimestamp(Long.parseLong(entity.getCreateTime()), MDateUtil.Format.FORMART5.name));
        } catch (NumberFormatException e) {

        }
    }
}
